//
//  SYBorderTextField.m
//  miniwangdai
//
//  Created by 容贤郁 on 15/12/23.
//  Copyright © 2015年 容贤郁. All rights reserved.
//

#import "SYBorderTextField.h"

@implementation SYBorderTextField


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    self.layer.masksToBounds = YES;
    self.layer.borderColor = [[UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:0.8]CGColor];
    self.layer.borderWidth = 1.0f;
}


- (CGRect)textRectForBounds:(CGRect)bounds {
    CGRect textRect = [super textRectForBounds:bounds];
    if (self.borderStyle == UITextBorderStyleNone) {
        
        
        textRect.origin.x += 5;
        textRect.size.width -= 10;
        return textRect;
    }
    return textRect;
}

- (CGRect)editingRectForBounds:(CGRect)bounds {
    
    CGRect editingRect = [super editingRectForBounds:bounds];
    if (self.borderStyle == UITextBorderStyleNone) {
        
        editingRect.origin.x += 5;
        editingRect.size.width -= 10;
    }
    return editingRect;
}

@end
